package ah.basic.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class OSExecute {

	public static void command(String command) {
		try {
			Process process = new ProcessBuilder(command.split(" ")).start();
			BufferedReader results = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
			String s;
			while ((s = results.readLine()) != null) {
				System.out.println(s);
			}
			
			BufferedReader errors = new BufferedReader(new InputStreamReader(process.getErrorStream(), "GBK"));
			
			while ((s = errors.readLine()) != null) {
				System.out.println(s);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		command("cmd /c dir&tt&dir&start excel");
	}
}
